<template>
     <input-select :id="id" :styles="styles" :options="options" isChange="Y"  :data="data"  @input="changeData" :exkey="exkey" :valsql="valsql" :sign="sign" :time="time"></input-select>

</template>
<script>
import InputSelect  from '../input/input-select'
export default {
    name:"lpSelect",
    props:['id','options','styles','value','data','index','isreadonly','isBorder','extype','valsql','appid','dataField','isSearch','isChange','exkey','sign','time','postUrl','isEdit'],
    components: {
        InputSelect
    },  
    data(){
        return{
            sfItemData:[]
        }
    },
    created(){
        this.$post("bygex","byg/funeral/getFuneralSfItem",{gm_id:this.gm_id,depart:this.depart}).then(data=>{
                console.log("created==================================")
                console.log(data,"sfItems================")
                this.sfItemData=[];
                for(let i=0;i<data.item.length;i++){
                    this.sfItemData.push(data.item[i]);
                }
                
                
            
            })
    },
    methods:{
        changeData(data){
            let item=JSON.parse(data);
            let ids=item.id.split(".");
            this.$set(this.data[ids[0]],ids[1],item.val)
            let szec_ex1=this.data["szInfoEx"]["szec_ex1"];
            let szec_ex2=this.data["szInfoEx"]["szec_ex2"];
            let szec_ex3=this.data["szInfoEx"]["szec_ex3"];

            console.log("szec_ex1=========="+szec_ex1+"="+szec_ex2+"="+szec_ex3);

            let row1=null;
            let row2=null;
            let row3=null;

            let isOk=true;
            while(isOk){
                let index=-1;
                for(let i=0;i<this.data.item.length;i++){
                    let szi_ex7=this.data.item[i].szi_ex7;
                    if(szi_ex7=='礼炮')
                        index=i;
                }
                if(index!=-1)
                    this.$delete(this.data["item"],index);
                else
                    isOk=false;
            }
            for(let i=0;i<this.sfItemData.length;i++){
                let szi_ex1=this.sfItemData[i].szi_ex1;
                if(szi_ex1==szec_ex1&&szec_ex1){
                    row1=this.sfItemData[i];
                }
                 if(szi_ex1==szec_ex2&&szec_ex2){
                    row2=this.sfItemData[i];
                }
                 if(szi_ex1==szec_ex3&&szec_ex3){
                    row3=this.sfItemData[i];
                }
            }
            console.log(this.sfItemData,"this.sfItemData================")
            console.log(row1,"row1================================")
            console.log(row2,"row2================================")
            console.log(row3,"row3================================")
            if(row1){
                row1.szi_ex13="业务"
                this.$set(this.data["item"],this.data.item.length,row1);
            }
            if(row2){
                row2.szi_ex13="业务"
                this.$set(this.data["item"],this.data.item.length,row2);
            }
            if(row3){
                row3.szi_ex13="业务"
                this.$set(this.data["item"],this.data.item.length,row3);
            }
           /* let item=JSON.parse(data);
            let datas={};
            datas.addType="string";
            datas.itemType='礼炮';
            datas.val=item.val;
            datas.hour=1;
            datas.day=1;
                 
            this.$emit("funeralItemSelectEvent",JSON.stringify(datas))*/
        }
    }
}
</script>